﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizzReports;
using System.Data;
using System.ComponentModel;
using System.Windows.Forms.Design;
using System.Windows.Forms;

namespace TraysStatsReport
{
    
    
    public class TraysMessageCountReport : IBizzCommand
    {
        
        public DateTime fromDate { get; set; }
        public DateTime toDate { get; set; }
        public DataTable reportData { get; set; }
        public TraysMessageCountReport()
        {
            fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            toDate = DateTime.Now;
            
            
            
        }
        public void Update()
        {
            if (ReportQuery == null)
                ReportQuery = new BizzQuery();
            DateTime toDatePlusOne = toDate;
            toDatePlusOne = toDatePlusOne.AddDays(1);
            ReportQuery.queryString = "select Inbox as 'Bandeja de entrada', InboxType as 'Tipo', count(1) as 'Cantidad de mensajes'" +
                                       " from messages where MsgDate >= '" + fromDate.ToString("yyyy/MM/dd") + "' And MsgDate <= '" + toDatePlusOne.ToString("yyyy/MM/dd") + "'" +
                                       " group by Inbox, InboxType";


             reportData = ReportQuery.ExecuteQuery().Tables[0];
        }

        public BizzQuery ReportQuery
        {
            get;
            set;
        }

     

        #region IBizzCommand Members


        public BizzReportTemplate showReportPanel()
        {
          

            return new TrayMsgReportUsercontrol(this);
        }

        public string Title
        {
            get { return "Mensajes por bandeja de entrada"; }
        }

        #endregion
    }
}
